<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>发货内容</title>
    <link href="../media/20210402010727Dn.png" rel="shortcut icon">
    <link rel="stylesheet" href="css/bootstrap.css">
    <script src="js/jquery.min.js"></script>
    <script src="js/bootstrap.min.js"></script>
    <script src="../js/qrcode.min.js"></script>
    <script src="../js/html2canvas.js"></script>
</head>
<body style="padding-top:0px">
<div class="container"><a href="../"><img src="../media/20210402011553yo.png" style="height:60px;margin:10px 0"></a> <a
        href="../" class="btn btn-primary pull-right" style="margin-top:20px;">返回首页</a>
    <div class="panel panel-primary">
        <div class="panel-heading">
            <h3 class="panel-title">订单信息</h3>
        </div>
        <div class="panel-body">
            <div class="row">
                <div class="col-md-3">
                    <p><img src="../media/20200930175640vX.jpg" width="100%"></p>
                </div>
                <div class="col-md-9">
                    <p>商品名称：求生之路2/Left 4 Dead 2（整合背水一战DLC）</p>
                    <p>商品规格：标配</p>
                    <p>商品价格：0.00元</p>
                    <p>购买数量：1件</p>
                    <p>购买时间：2022-08-29 02:29:16</p>
                    <p>收货信息：免费商品，无需邮箱</p>
                    <p>付款方式：</p>
                    <p>订单编号：2022082902291616736169</p>
                </div>
            </div>
        </div>
    </div>
    <div class="panel panel-primary">
        <div class="panel-heading">
            <h3 class="panel-title">发货内容</h3>
        </div>
        <div class="panel-body">
     <textarea class="form-control" rows="5" id="content_copy">解压码：382988
天翼：https://cloud.189.cn/t/QruqieuEz2Qn
百度：https://pan.baidu.com/s/1RqXmYZIDaISkcV_e4qTdTA?pwd=761d
提取码：761d</textarea>
            <button class="btn btn-info" style="margin-top:10px;" onclick="copy()">复制</button>
            <button class="btn btn-success" style="margin-top:10px;" onclick="qr()">生成二维码</button>
        </div>
    </div>
</div>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h4 class="modal-title" id="myModalLabel">生成二维码</h4>
            </div>
            <div class="modal-body" style="text-align:center">
                <div id="billImage" style="display:inline-block"></div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary" onclick="save()">保存二维码</button>
            </div>
        </div>
    </div>
</div>
<script>
    function copy() {
        var e = document.getElementById("content_copy");
        e.select();
        document.execCommand("Copy");
        alert("复制成功")
    }

    function qr() {
        qrcode.makeCode(window.location.href);
        $("#myModal").modal("show");
    }

    function save() {
        var copyDom = $("#billImage"); //要保存的dom
        var width = copyDom.offsetWidth; //dom宽
        var height = copyDom.offsetHeight; //dom高
        var scale = 2; //放大倍数

        html2canvas(
            copyDom[0],
            {
                dpi: window.devicePixelRatio * 2,
                scale: scale,
                width: width,
                heigth: height,
                useCORS: true,
                onrendered: function (canvas) {
                    var pageData = canvas.toDataURL("image/png", 1.0);
                    console.log(pageData)
                    saveFile(pageData.replace("image/png", "image/octet-stream"), new Date().getTime() + ".png");
                }
            })
    }

    function convertCanvasToImage(canvas) {
        var image = new Image();
        image.src = canvas.toDataURL("image/png");
        document.body.appendChild(image);
        return image;
    }

    function saveFile(data, filename) {
        var save_link = document.createElementNS("http://www.w3.org/1999/xhtml", "a");
        save_link.href = data;
        save_link.download = filename;

        var event = document.createEvent("MouseEvents");
        event.initMouseEvent("click", true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
        save_link.dispatchEvent(event);
    };

    var qrcode = new QRCode("billImage", {
        width: 300,
        height: 300,
        colorDark: "#000000",
        colorLight: "#ffffff",
        correctLevel: QRCode.CorrectLevel.H
    });
</script>
</body>
</html>
